<template>
    <view class="g_content p_20">
        <s-goods :goodsList="list" :isLike="true" @handleLike="handleLike"></s-goods>
                <!-- 授权弹窗 -->
        <s-auth-modal />
    </view>
</template>
<script>
import {myMixins} from "@/mixins/myMixins";
import {getCollectListApi,addCollectApi,delCollectApi } from "@/sheep/api/index";
export default {
    mixins:[myMixins],
    name: "mySend",
    data() {
        return {
            list:[],
        }
    },
    onShow() {
        this.updateData()
    },
    methods:{
        getList(){
            getCollectListApi(this.queryObj).then(res=>{
                this.list = this.list.concat(res.rows)
                this.total = res.total
                if (this.queryObj.pageNum*this.queryObj.pageSize<this.total){
                    this.status = 'loadmore'
                }else{
                    this.status = 'nomore'
                }
                uni.stopPullDownRefresh()
            })
        },
        handleTab(e){},
        handleLike(item){
            if (item.sfxh){
                delCollectApi({inFormationId:item.id}).then(res=>{
                    uni.showToast({
                        title: res.msg,
                        icon: "none",
                        duration: 2000
                    });
                    if(res.code==200){
                        this.updateData()
                    }
                })
            }else{
                addCollectApi({userIdPassivity:item.id}).then(res=>{
                    uni.showToast({
                        title: res.msg,
                        icon: "none",
                        duration: 2000
                    });
                    if(res.code==200){
                        this.updateData()
                    }
                })
            }
        }
    }
}
</script>

<style scoped lang="scss">

</style>
